package com.zd.kids.ui.view;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;

import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView;
import com.zd.kids.BuildConfig;
import com.zd.kids.R;

import androidx.annotation.NonNull;

/**
 * @ClassName: com.zd.kids.ui.view
 * @Description:
 * @Author: hyy
 * @Date: 2020/8/31
 * @Time: 5:36 PM
 */
public class QuquesPermissionDialog extends BottomPopupView {
    private Context context;


    public QuquesPermissionDialog(@NonNull Context context) {
        super(context);
        this.context = context;
    }


    @Override
    protected void init() {
        super.init();

        findViewById(R.id.tv_confirm).setOnClickListener(view -> {
            Uri packageURI = Uri.parse("package:" + BuildConfig.APPLICATION_ID);
            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageURI);
            context.startActivity(intent);
        });

    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.layout_request_permission_dialog;
    }


    public void showView() {
        new XPopup.Builder(getContext())
                .dismissOnBackPressed(false)
                .dismissOnTouchOutside(false)
                .asCustom(this)
                .show();
    }
}
